define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params, configService) {
        $scope.form = {};
        $scope.menu_name = "添加考点";
        $scope.changeUnit = {};

        //查询教师信息
        httpService.post(app.urls.teacher_selectById,{"id":params.id},function(data){
            if("0000" === data.code){
                $scope.user = data.data;
                $scope.changeUnit.gzdwpk_new = $scope.user.gzdwpk;
                $scope.changeUnit.rsdwpk_new = $scope.user.rsdwpk;
            }else{
                alert(data.msg);
            }
        });

        //查询所有单位
        httpService.post(app.urls.unit_selectUnit,{},function(data){
            if("0000" === data.code){
                $scope.units = data.data;
            }else{
                alert(data.msg);
            }
        });

        //查询单位更换申请
        httpService.post(app.urls.findUnitChangeURL,{"fk_user": params.id},function(data){
            if("0000" === data.code){
                let changeUnitList = data.data;
                if (changeUnitList.length > 0){
                    $scope.changeUnit = data.data[0];
                }
            }else{
                alert(data.msg);
            }
        });

        /**
         * 保存
         */
        $scope.save = function() {
            if ($scope.changeUnit.changestate == 0){
                eventBusService.publish('modal.alert', {"title":"操作提示", "content":"正在审核中，无法再次申请更换单位！"});
                return;
            }

            let pObj ={
                "fk_user": params.id,
                "gzdwpk_old": $scope.user.gzdwpk,
                "rsdwpk_old": $scope.user.rsdwpk,
                "gzdwpk_new": $scope.changeUnit.gzdwpk_new,
                "rsdwpk_new": $scope.changeUnit.rsdwpk_new
            };

            httpService.post(app.urls.addUnitChangeURL, pObj, function(data){
                if("0000" === data.code){
                    eventBusService.publish("content.page.reload."+params.FatherControllerName,data.data);
                    eventBusService.publish("modal.page.close",{});
                }else{
                    alert(data.msg);
                }
            });
        }

}}});
